import 'package:flutter/material.dart';
import 'package:icooker/pages/home/final_page_home.dart';
import 'package:icooker/pages/home/page_classic.dart';
import 'package:icooker/pages/home/page_comment.dart';
import 'package:icooker/pages/home/page_excellent.dart';
import 'package:icooker/pages/home/page_profile.dart';
import 'package:icooker/providers/main_provider.dart';
import 'package:provider/provider.dart';

// Main界面主体内容
class MainBody extends StatelessWidget {
  MainBody({Key? key}) : super(key: key);
  List<Widget> pages = [
    FinalPageHome(),
    ClassicPage(),
    ExcellentPage(),
    CommentPage(),
    ProfilePage()
  ];

  @override
  Widget build(BuildContext context) {
    var provider = Provider.of<MainProvider>(context);
    return PageView.builder(
      physics: NeverScrollableScrollPhysics(),
      controller: provider.pageController,
      onPageChanged: (index) {
        provider.switchTabbar(index);
      },
      itemBuilder: (context, index) {
        return pages[index];
      },
      itemCount: pages.length,
    );
  }
}
